﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Data;
namespace WPFExcelReport
{
    public partial class TGV02 : ViewBase
    {
        #region ==LIEFSCH===========
        public static readonly DependencyProperty LIEFSCHProperty = DependencyProperty.Register("LIEFSCH",
            typeof(string), typeof(TGV02),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFSCHChanged));
        public string LIEFSCH
        {
            get
            {
                return (string)GetValue(LIEFSCHProperty);
            }
            set
            {
                SetValue(LIEFSCHProperty, value);
            }
        }
        private static void OnLIEFSCHChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TGV02;
            if (src != null)
            {
                src.LIEFSCH = (string)e.NewValue;
                src.Load();
            }
        }
        #endregion 
       
        VGPACK VGPACK;
        public TGV02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVVPACK();
            this.DataContext = MV;
            InitializeComponent();  
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e); 
        }
        string LastLIEFSCH = "";
        public void Load()
        {
            if (LastLIEFSCH == LIEFSCH)
                return;
            LastLIEFSCH = LIEFSCH;
            DataRow dwData = MV.SetEnv.Tables["VVPACK"].NewRow();
            dwData["VVPMANDANT"] = app.Mandant;
            dwData["VVPLIEFSCH"] = LIEFSCH;
            DataSet SResult = ((VVVPACK)MV).QueryVVPACK(dwData, 4);
            MergeData(SResult);
        }
    }
}